<template>
	<view class="mainpadding" style="padding-bottom: 150rpx;" v-if="pageShow">
		<!-- 1=待支付,2=待乘车,3=已完成,4=取消审核中,5=已取消 -->
		<view class="xiaohei bigtext textcenter fonweight" v-if="dataAll.state==2">{{dataAll.cc_time_text}} {{dataAll.start_tourist_site_time}}出发</view>
		<view class="" v-if="dataAll.state!=2">
			<text class="xiaohei ershiba">订单状态：</text>
			<text class="xiaohong ershiba" v-if="dataAll.state==1">待支付</text>
			<text class="xiaolan ershiba" v-if="dataAll.state==2">待出行</text>
			<text class="xiaolv ershiba" v-if="dataAll.state==3">已完成</text>
			<view class="xiaohuang ershiba" v-if="dataAll.state==4">取消审核中</view>
			<text class="xiaohui ershiba" v-if="dataAll.state==5">已取消</text>
		</view>
		<view class="mainpadding_top ffffff radius">
			<view class="flexbetween">
				<view class="xiaohei sanshier">上车点</view>
				<!-- <image src="@/static/image/system/navigation.png" style="width: 60rpx;height: 60rpx;" mode=""></image> -->
			</view>
			<view class="margin_top2">
				<text class="lvdian margin_right2"></text>
				<text class="xiaohui ershiba ">{{dataAll.start_tourist_site_time}}  {{dataAll.start_tourist_site_name}}</text>
			</view>
			<view class="flexbetween">
				<view class="xiaohei margin_top sanshier">下车点</view>
				<!-- <image src="@/static/image/system/navigation.png" style="width: 60rpx;height: 60rpx;" mode=""></image> -->
			</view>
			<view class="margin_top2">
				<text class="huangdian margin_right2"></text>
				<text class="xiaohui ershiba ">{{dataAll.end_tourist_site_time}}  {{dataAll.end_tourist_site_name}}</text>
			</view>
		</view>
		<view class="mainpadding_top ffffff radius">
			<view class="xiaohei sanshier">乘车人信息</view>
			<view class="xiahuaxian margin_top" v-for="item in dataAll.goods" :key="item.id">
				<view>
					<text class="xiaohei ershiba margin_right3">{{item.name}}</text>
					<text class="xiaohei lable">{{item.datatype}}</text>
				</view>
				<view class="xiaohui margin_top1 ershil">证件号：{{item.idcard}}</view>
			</view>
		</view>
		<view class="mainpadding_top flexcolumn ffffff radius" v-if="dataAll.state==2">
			<view class="xiaohei textcenter sanshier">核销码</view>
			<uqrcode ref="uqrcode" canvas-id="qrcode" @click="ewmfn" v-bind:value="listid" :options="{ margin: 10}"
				size="150">
			</uqrcode>
		</view>
		<view class="mainpadding_top ffffff radius">
			<view class="xiaohei sanshier">订单信息</view>
			<view class="flexbetween margin_top">
				<view class="xiaohui ershil">订单总金额</view>
				<view class="xiaolan titletext fonweight">￥{{dataAll.pay_price}}</view>
			</view>
			<view class="flexbetween margin_top" v-if="dataAll.state==2 || dataAll.state==3">
				<view class="xiaohui ershil">支付方式</view>
				<view class="xiaohei titletext fonweight">{{dataAll.pay_status==10?'微信支付':'次数支付'}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="xiaohui ershil">订单编号</view>
				<view class="xiaohei titletext fonweight">{{dataAll.order_no}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="xiaohui ershil">创建时间</view>
				<view class="xiaohei titletext fonweight">{{dataAll.createtime_text}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="xiaohui ershil">发车时间</view>
				<view class="xiaohei titletext fonweight">{{dataAll.cc_time_text}} {{dataAll.start_tourist_site_time}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="xiaohui ershil">联系人</view>
				<view class="xiaohei titletext fonweight">{{dataAll.lxname}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="xiaohui ershil">联系电话</view>
				<view class="xiaohei titletext fonweight">{{dataAll.lxtel}}</view>
			</view>
			<view class="margin_top" v-if="dataAll.remarks!=-''">
				<view class="xiaohui ershil">备注</view>
				<view class="xiaohei margin_top1 titletext fonweight">{{dataAll.remarks}}</view>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding">
			<view class="flexright">
				<view class="listbaibtn strongtext margin_left3 xiaohui" v-if="dataAll.state==1 || dataAll.state==2" @click.stop="cancelOrder(dataAll.id)">取消订单</view>
				<view class="listlanbtn strongtext margin_left3 xiaobai" v-if="dataAll.state==1" @click.stop="pay(dataAll)">立即支付</view>
				<view class="listlanbtn strongtext margin_left3 xiaobai" @click="callphone(dataAll.tourist_time.tel)">随车电话</view>
				<view class="listbaibtn strongtext margin_left3 xiaohui" v-if="dataAll.state==3 || dataAll.state==5" @click.stop="delOrder(dataAll.id)">删除订单</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				dataAll:{},
				pageShow:false,
				listid:""
			}
		},
		onLoad(options) {
			this.listid = options.id
		},
		onShow() {
			this.getdetail()
		},
		methods: {
			// 二维码点击预览图片
			ewmfn() {
				this.$refs.uqrcode.toTempFilePath({
					success: res => {
						console.log(res);
						var i = [res.tempFilePath]; //获取当前页面的轮播图数据
						//uniapp预览轮播图
						uni.previewImage({
							current: 0, //预览图片的下标
							urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
						})
					}
				});
			},
			getdetail(){
				httpRequest.request('/api/Travelcl/getOrderInfo','GET',{
					id:this.listid
				}).then(res => {
					this.dataAll = res.data
					this.pageShow = true
				})
			},
			cancelOrder(id) {
				httpRequest.modal('提示', '是否确认取消订单', true, (resp) => {
					if (resp) {
						httpRequest.request("/api/Travelcl/cancelOrder", 'POST', {
							 order_id:id
						}).then(res => {
							httpRequest.toast(res.msg)
							if (res.code == 1) {
								this.getdetail()
							}
						})
					}
				})
			},
			delOrder(id) {
				httpRequest.modal('提示', '是否确认删除订单', true, (resp) => {
					if (resp) {
						httpRequest.request("/api/Travelcl/delOrder", 'POST', {
							id
						}).then(res => {
							httpRequest.toast(res.msg)
							if (res.code == 1) {
								this.getdetail()
							}
						})
					}
				})
			},
			pay(item) {
				uni.navigateTo({
					url:"/pages/index/zhifu?order_id="+item.id+"&pay_price="+item.pay_price
				})
			},
		}
	}
</script>

<style>
.lable {
		padding: 0 8rpx;
		border: 1rpx solid #999;
		font-size: 20rpx;
	}
</style>
